<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of dem2ddat</title>
  <meta name="keywords" content="dem2ddat">
  <meta name="description" content="DEM2DDAT Generates two dimensional data for demos.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; dem2ddat.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>dem2ddat
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>DEM2DDAT Generates two dimensional data for demos.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [data, c, prior, sd] = dem2ddat(ndata) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">DEM2DDAT Generates two dimensional data for demos.

    Description
    The data is drawn from three spherical Gaussian distributions with
    priors 0.3, 0.5 and 0.2; centres (2, 3.5), (0, 0) and (0,2); and
    standard deviations 0.2, 0.5 and 1.0.  DATA = DEM2DDAT(NDATA)
    generates NDATA points.

    [DATA, C] = DEM2DDAT(NDATA) also returns a matrix containing the
    centres of the Gaussian distributions.

    See also
    <a href="demgmm1.html" class="code" title="">DEMGMM1</a>, DEMKMEAN, <a href="demknn1.html" class="code" title="">DEMKNN1</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="demgmm2.html" class="code" title="">demgmm2</a>	DEMGMM1 Demonstrate density modelling with a Gaussian mixture model.</li><li><a href="demkmn1.html" class="code" title="">demkmn1</a>	DEMKMEAN Demonstrate simple clustering model trained with K-means.</li><li><a href="demknn1.html" class="code" title="">demknn1</a>	DEMKNN1 Demonstrate nearest neighbour classifier.</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [data, c, prior, sd] = dem2ddat(ndata)</a>
0002 <span class="comment">%DEM2DDAT Generates two dimensional data for demos.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%    Description</span>
0005 <span class="comment">%    The data is drawn from three spherical Gaussian distributions with</span>
0006 <span class="comment">%    priors 0.3, 0.5 and 0.2; centres (2, 3.5), (0, 0) and (0,2); and</span>
0007 <span class="comment">%    standard deviations 0.2, 0.5 and 1.0.  DATA = DEM2DDAT(NDATA)</span>
0008 <span class="comment">%    generates NDATA points.</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%    [DATA, C] = DEM2DDAT(NDATA) also returns a matrix containing the</span>
0011 <span class="comment">%    centres of the Gaussian distributions.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%    See also</span>
0014 <span class="comment">%    DEMGMM1, DEMKMEAN, DEMKNN1</span>
0015 <span class="comment">%</span>
0016 
0017 <span class="comment">%    Copyright (c) Ian T Nabney (1996-2001)</span>
0018 
0019 input_dim = 2;
0020 
0021 <span class="comment">% Fix seed for reproducible results</span>
0022 randn(<span class="string">'state'</span>, 42);
0023 
0024 <span class="comment">% Generate mixture of three Gaussians in two dimensional space</span>
0025 data = randn(ndata, input_dim);
0026 
0027 <span class="comment">% Priors for the three clusters</span>
0028 prior(1) = 0.3;
0029 prior(2) = 0.5;
0030 prior(3) = 0.2;
0031 
0032 <span class="comment">% Cluster centres</span>
0033 c = [2.0, 3.5; 0.0, 0.0; 0.0, 2.0];
0034 
0035 <span class="comment">% Cluster standard deviations</span>
0036 sd  = [0.2 0.5 1.0];
0037 
0038 <span class="comment">% Put first cluster at (2, 3.5)</span>
0039 data(1:prior(1)*ndata, 1) = data(1:prior(1)*ndata, 1) * 0.2 + c(1,1);
0040 data(1:prior(1)*ndata, 2) = data(1:prior(1)*ndata, 2) * 0.2 + c(1,2);
0041 
0042 <span class="comment">% Leave second cluster at (0,0)</span>
0043 data((prior(1)*ndata + 1):(prior(2)+prior(1))*ndata, :) = <span class="keyword">...</span>
0044     data((prior(1)*ndata + 1):(prior(2)+prior(1))*ndata, :) * 0.5;
0045 
0046 <span class="comment">% Put third cluster at (0,2)</span>
0047 data((prior(1)+prior(2))*ndata +1:ndata, 2) = <span class="keyword">...</span>
0048     data((prior(1)+prior(2))*ndata+1:ndata, 2) + c(3, 2);</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>